﻿using ERP.Inventory.Api.Write.Application.Command.库存管理;
using ERP.Inventory.Errorcode;
using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace ERP.Inventory.Api.Write.Controllers
{
    /// <summary>
    /// 工单控制器
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class CheckController : ControllerBase
    {
        private readonly IMediator mediator;
        private readonly ILogger<CheckController> logger;

        public CheckController(IMediator mediator, ILogger<CheckController> logger)
        {
            this.mediator = mediator;
            this.logger = logger;
        }
        /// <summary>
        /// 新增盘点
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public Task<ApiResult<int>> CreateCheck(CreateCheckCommand request)
        {
            //异常处理
            try
            {
                return mediator.Send(request);
            }
            catch (Exception)
            {

                throw;
            }
        }
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public Task<ApiResult<int>> DelCheck(DelCheckCommand request)
        {
            //异常处理
            try
            {
                return mediator.Send(request);
            }
            catch (Exception)
            {

                throw;
            }
        }
        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public Task<ApiResult<int>> UpdateCheck(UpdateCheckCommand request)
        {
            //异常处理
            try
            {
                return mediator.Send(request);
            }
            catch (Exception)
            {

                throw;
            }
        }
        /// <summary>
        /// 中间表的添加
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public  Task<ApiResult<int>> CheckShopCreate(CheckShopCreateCommand request)
        {
            //异常处理
            try
            {
                return mediator.Send(request);
            }
            catch (Exception)
            {

                throw;
            }
        }
    }
}
